import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
//导入富文本编辑器 相关样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
//全局挂载富文本编辑器组件
Vue.use(VueQuillEditor)

Vue.config.productionTip = false

//设置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//axios请求拦截
axios.interceptors.request.use(config => {
  //在请求头中加上参数Authorization，值为token
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
//将axios对象挂在到Vue组件上
Vue.prototype.$http = axios

//将树表格组件注册到Vue全局上
Vue.component('treeTable',TreeTable)

//注册时间处理过滤器
Vue.filter('dateformate', function(time){
  let date = new Date(time);
  let year = date.getFullYear();
  let month = (date.getMonth()+'').padStart(2,'0');
  let day = (date.getDate()+'').padStart(2,'0');
  let hour = (date.getHours()+'').padStart(2,'0');
  let min = (date.getMinutes()+'').padStart(2,'0');
  let seconds = (date.getSeconds()+'').padStart(2,'0');
  return  year +'-'+ month +'-'+ day + ' '+ hour + '/' +min+'/'+seconds
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
